﻿using System;
using System.Reflection;
using Microsoft.Phone.Tasks;

namespace Mangopollo.Tasks
{
    public class MapsDirectionsTask
    {
        // Summary:
        //     The ending location for which driving directions are displayed.
        //
        // Returns:
        //     Type: Microsoft.Phone.Tasks.LabeledMapLocation. The ending location for which
        //     driving directions are displayed.
        public LabeledMapLocation End { get; set; }
        //
        // Summary:
        //     The starting location for which driving directions are displayed.
        //
        // Returns:
        //     Type: Microsoft.Phone.Tasks.LabeledMapLocation. The starting location for
        //     which driving directions are displayed.
        public LabeledMapLocation Start { get; set; }

        public void Show()
        {
            Type taskDataType = Type.GetType("Microsoft.Phone.Tasks.MapsDirectionsTask, Microsoft.Phone");
            object task = taskDataType.GetConstructor(new Type[] {}).Invoke(null);
            Utils.SetProperty(task, "Start", Start);
            Utils.SetProperty(task, "End", End);
            MethodInfo showmethod = taskDataType.GetMethod("Show");
            showmethod.Invoke(task, new object[] {});
        }
    }
}